package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.NewsRecordService;
import com.woniu.p2p.entity.New;
import com.woniu.p2p.mapper.NewMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * NewsRecordServiceImpl
 *
 * @author 郭耀文
 * @date 2020/8/13
 */
@Service
public class NewsRecordServiceImpl implements NewsRecordService {

    @Autowired
    NewMapper newMapper;

    @Override
    public PageInfo<New> selecNewsByName(String name, Integer start) {
        PageHelper.startPage(start, 3);

        List<New> list = newMapper.findByNewName(name);

        PageInfo<New> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int AddNews(New news) {
        return newMapper.insert(news);
    }

    @Override
    public int delectNews(Integer newId) {
        return newMapper.deleteByPrimaryKey(newId);
    }

    @Override
    public int updateNews(New news) {
        return newMapper.updateByPrimaryKey(news);
    }
}
